x, y = map(int, input().split())


def twosum(nums,target):
    count = 0
    hashmap = {}
    for i, x in enumerate(nums):
        y = target - x
        if y in hashmap:
            count += 1
        hashmap[x] = i
    return count

def nSum(s):
    for i in range(1, s+1):
        if (i*(i+1))//2 == s:
            return i
    return

flag = nSum(x+y)
if not flag:
    print(-1)
else:
    l = [i for i in range(1, flag+1)]
    res = twosum(l, x)
    print(res)
